feat: Integrate Jolt Physics as native host service in SpacetimeDB#1
Open
feat: Integrate Jolt Physics as native host service in SpacetimeDB#1
Conversation
Add Jolt Physics 5.0.0 as a native C++ host service accessible from WASM modules via host functions. Includes: - JoltC C API: Vehicle system (WheeledVehicleController) with structs for vehicle params, wheel state, and full vehicle state - Rust physics service: PhysicsState singleton managing multiple physics worlds, body creation/destruction, vehicle support, and 2-layer broadphase - WASM host functions: 18 physics_* functions in spacetime_10.5 namespace bridging WASM memory to native Jolt calls - C# bindings: High-level Physics.cs wrapper with serialization for FFI - Test module: physics-test-cs with tables, reducers, and 30Hz physics tick Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the vendored joltc-sys-patched folder (~577 files, 11MB) with a git dependency pointing to pbisogno/jolt-rust feature/spacetimedb branch. The Jolt Physics code now lives in its own fork chain: - pbisogno/jolt-rust (build.rs patches for Windows/SpacetimeDB) - pbisogno/JoltC (Vehicle API additions) - jrouwe/JoltPhysics (upstream, unchanged) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Each module now owns its own Arc<PhysicsState>, ensuring: - Module A cannot access Module B's physics worlds - Physics resources are automatically cleaned up when a module is dropped - Multiple database instances can run independent physics simulations The PhysicsState flows through: ModuleCommon -> InstanceEnv -> host functions. Removed the global static PHYSICS singleton and physics() accessor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace as_raw() with raw() to match current rolt/joltc-sys API - Add ? operator for create_body return type (now returns Option) - Fix borrow-then-move issue in v8/mod.rs by cloning physics Arc early - Add build_check.ps1 with MSVC + Strawberry Perl + LLVM setup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Jolt Physics 5.0.0 as a native C++ host service accessible from WASM modules via host functions. Includes:
Description of Changes
API and ABI breaking changes
Expected complexity level and risk
Testing